package com.leetcode.demo3Solution.java;

import java.util.ArrayList;

public class demo8MyAtoi {
    public static void main(String[] args) {
           System.out.println("桃子:"+myAtoi("6578mainj"));
           System.out.println("桃子大帅比");
    }


        public static int myAtoi(String str) {
            ArrayList<Character> alist=new ArrayList<Character>();
            if((65<=str.charAt(0)&&str.charAt(0)<=90)||(97<=str.charAt(0)&&str.charAt(0)<=122)||str.isEmpty()||str.equals("")){
                return  0;
            }
            for(int i=0;i<str.length();i++){
                if((48<=str.charAt(i)&&str.charAt(i)<=57)){
                     alist.add(str.charAt(i));
                }

            }
            return Integer.parseInt(alist.toString().replaceAll("",""));
        }

}
